package lrg10002.exostention.element;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import net.minecraft.item.ItemStack;

public class ItemMakeupManager {

	public static ElementType[] getMakeup(ItemStack is) {
		return null;
	}

	public static void loadItemMakeups() {

	}

	static class MakeupContainer {

		private LinkedList<Integer> ids = new LinkedList<Integer>();
		private LinkedList<Integer> meta = new LinkedList<Integer>();
		private LinkedList<ArrayList<Integer>> grid = new LinkedList<ArrayList<Integer>>();

		public MakeupContainer() {
		}

		public void initItem(ItemStack is, ArrayList<Integer> ma) {
			if (!ids.contains(is.itemID)) { // no item yet
				ids.addLast(is.itemID);
				meta.addLast(is.getItemDamage());
				grid.addLast(ma);
			} else {
				boolean add = true;
				for (int x = 0; x < ids.size(); x++) {
					int i = ids.get(x);
					if (i == is.itemID && meta.get(x) == is.getItemDamage()) {
						// it already exists
						add = false;
					}
				}
				if (add) {
					ids.addLast(is.itemID);
					meta.addLast(is.getItemDamage());
					grid.addLast(ma);
				}
			}
		}

		public Makeup getMakeup(ItemStack is) {
			for (int x = 0; x < ids.size(); x++) {
				int i = ids.get(x);
				if (i == is.itemID && meta.get(x) == is.getItemDamage()) {
					return new Makeup(is.itemID, is.getItemDamage(), grid.get(x));
				}
			}
			return null;
		}
	}

	static class Makeup {
		public int id;
		public int meta;
		public List<ElementType> grid = new ArrayList<ElementType>();

		public Makeup(int id, int meta, ArrayList<Integer> grid) {
			this.id = id;
			this.meta = meta;
			for (int i : grid) {
				this.grid.add(ElementType.ELEMENT_TYPES[i]);
			}
		}
	}

}
